package com.nescafe.nescafepromo.model;

import java.util.ArrayList;
import java.util.List;

import com.google.appengine.api.datastore.Cursor;
import com.google.appengine.api.datastore.Entity;
import com.nescafe.nescafepromo.NescafePromoException;
import com.nescafe.nescafepromo.entity.NPEntity;

public class NPResponse {

	private boolean hasError = false;
	private NescafePromoException exception = null;
	private List<Entity> results = new ArrayList<Entity>();
	private ParticipantDetailList participantDetailList = null;
	private MainPageInfo mainPageInfo = new MainPageInfo();
	private String message = null;
	private Cursor cursor = null;

	public NPResponse(String message) {
		this.message = message;
	}

	public NPResponse(NPEntity entity) {

	}

	public NPResponse(List<Entity> entityList) {
		this.results = entityList;
	}

	public NPResponse(ParticipantDetailList participantDetailList) {
		this.participantDetailList = participantDetailList;
	}

	public NPResponse(MainPageInfo mainPageInfo) {
		this.mainPageInfo = mainPageInfo;
	}

	public NPResponse(NescafePromoException ex) {
		this.exception = ex;
		hasError = true;
		this.message = ex.getMessage();
	}

	public MainPageInfo getMainPageInfo() {
		return mainPageInfo;
	}

	public List<Entity> getResults() {
		return results;
	}

	public void setParticipantDetailList(ParticipantDetailList participantDetailList) {
		this.participantDetailList = participantDetailList;
	}

	public ParticipantDetailList getParticipantDetailList() {
		return participantDetailList;
	}

	public void setCursor(Cursor cursor) {
		this.cursor = cursor;
	}
	public Cursor getCursor() {
		return cursor;
	}

	public String getMessage() {
		return message;
	}

	public void setMessage(String message) {
		this.message = message;
	}

	public NescafePromoException getException() {
		return exception;
	}

	public String toJson() {
		StringBuilder sb = new StringBuilder();
		sb.append("{'error':'");
		sb.append(hasError);
		sb.append("'}");
		return sb.toString();
	}

}
